package com.hushow.demo.controller;



import com.hushow.demo.helloworld.DubboGreeterGrpc;
import com.hushow.demo.helloworld.HelloReply;
import com.hushow.demo.helloworld.HelloRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("grpc")
public class RpcProxyController {

    @DubboReference
    private DubboGreeterGrpc.IGreeter greeter;


    @RequestMapping("/hello")
    public String hello(@RequestParam("name") String name){

        log.info("yyyyy hRpcProxyController.hello:{}", name);

        HelloRequest request = HelloRequest.newBuilder().setName(name).build();
        HelloReply response =  greeter.sayHello(request);
        return response.getMessage();
    }

}
